package com.smart.campus.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.smart.campus.dao.ProtectiveGuidanceManagementMapper;
import com.smart.campus.dto.ProtectiveGuidanceManagement;
import com.smart.campus.pojo.PagedResponse;
import com.smart.campus.service.ProtectiveGuidanceManagementService;
import com.smart.campus.util.PaginationUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @BelongsProject: smart-campus
 * @BelongsPackage: com.smart.campus.service.impl
 * @Author: 戴冰洁
 * @CreateTime: 2024-09-22  19:27
 * @Description: TODO
 * @Version: 1.0
 */
@Service
public class ProtectiveGuidanceManagementServiceImp implements ProtectiveGuidanceManagementService {
    @Autowired
    private ProtectiveGuidanceManagementMapper protectiveGuidanceManagementMapper;

    @Override
    public List<ProtectiveGuidanceManagement> protectiveList() {
        return protectiveGuidanceManagementMapper.selectList(null);
    }

    @Override
    public void addprotective(ProtectiveGuidanceManagement protectiveGuidanceManagement) {

        protectiveGuidanceManagementMapper.insert(protectiveGuidanceManagement);
    }

    @Override
    public ProtectiveGuidanceManagement protectiveById(Integer id) {
        return protectiveGuidanceManagementMapper.selectById(id);
    }

    @Override
    public PagedResponse<ProtectiveGuidanceManagement> protectiveListById(ProtectiveGuidanceManagement protectiveGuidanceManagement, Integer pageNum, Integer pageSize) {
        Page<ProtectiveGuidanceManagement> protectiveGuidanceManagementPage = new Page<>(pageNum, pageSize);
        QueryWrapper<ProtectiveGuidanceManagement> protectiveGuidanceManagementQueryWrapper = new QueryWrapper<>();
        Page<ProtectiveGuidanceManagement> protectiveGuidanceManagementPage1 = protectiveGuidanceManagementMapper.selectPage(protectiveGuidanceManagementPage, protectiveGuidanceManagementQueryWrapper);
        return PaginationUtil.getPaginationResponse(protectiveGuidanceManagementPage1.getRecords(),pageNum,pageSize,protectiveGuidanceManagementPage1.getTotal());
    }

    @Override
    public void updateprotective(ProtectiveGuidanceManagement protectiveGuidanceManagement) {
        protectiveGuidanceManagementMapper.updateById(protectiveGuidanceManagement);
    }

    @Override
    public void deleteprotective(Integer id) {
        protectiveGuidanceManagementMapper.deleteById(id);
    }
}
